package com.sugar.queryinfo.module.business.dal.mysql.userauth;

import java.util.*;

import cn.hutool.core.util.StrUtil;
import com.sugar.queryinfo.framework.common.pojo.PageResult;
import com.sugar.queryinfo.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.sugar.queryinfo.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.queryinfo.module.business.dal.dataobject.userauth.UserAuthDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.queryinfo.module.business.controller.admin.userauth.vo.*;

/**
 * 用户授权维护 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface UserAuthMapper extends BaseMapperX<UserAuthDO> {

    default PageResult<UserAuthDO> selectPage(UserAuthPageReqVO reqVO, Long userId) {
        String name = reqVO.getName();
        List<String> names = null;
        if (StrUtil.isNotBlank(name)){
            names = Arrays.asList(name.split(","));
        }
        return selectPage(reqVO, new LambdaQueryWrapperX<UserAuthDO>()
                .inIfPresent(UserAuthDO::getName, names)
                .eqIfPresent(UserAuthDO::getUserId, userId)
                .orderByDesc(UserAuthDO::getId));
    }

}